{literal}
    <script type="text/javascript">
    $(function() {
        /* Chargement du selectbox par ajax */
        $("#ess_iMarqueId").change(function(){
            var zUrlModel = "{/literal}{jurl 'essais~BoFiches:ajaxGetModelByMarqueId', array(), false}{literal}" ;
            $.post(zUrlModel,{iMarqueId: $(this).val()}, function(modele){
              var options = '';
              for (var i = 0; i < modele.length; i++) {
                options += '<option value="' + modele[i].modele_id + '">' + modele[i].modele_libelle + '</option>';
              }
              $("#ess_iModelId").html(options);
            });
        });
    });
    </script>
    <style type="text/css">
        #caract-left {width:45%;float:left;}
        #caract-right {width:50%;float:right;margin-right:30px;}
    </style>
{/literal} 
<h2>Entrez les caractéristiques du véhicule</h2>

<div id="caracteristique" style="background-color:#ECF8FD;float:left; margin-bottom:15px;">
   <div id="caract-left">

      <dl>
        <dt><label>Catégorie : </label></dt>
        <dd>
            <select id="ess_iCatId" name="ess_iCatId" style="width:158px;">
                {foreach $toCatVoitures as $oCatVoiture}
                <option value="{$oCatVoiture->catV_id}"
                        {if (isset($voiture) && ($oCatVoiture->catV_id == $voiture->Occas_Groupe))} selected {/if}
                        >{$oCatVoiture->catV_zLibelle|escxml}</option>
                {/foreach}
            </select>
        </dd>
      </dl>
      <dl>
        <dt><label>Marque : </label></dt>
        <dd>
            <select id="ess_iMarqueId" name="ess_iMarqueId" style="width:158px;">
                {foreach $toMarqueVoitures as $oMarqueVoiture}
                <option value="{$oMarqueVoiture->marque_id}"
                        {if (isset($voiture) && ($oMarqueVoiture->marque_id == $voiture->Occas_Marque))} selected {/if}
                        >{$oMarqueVoiture->marque_libelle|escxml}</option>
                {/foreach}
            </select>
        </dd>
      </dl>
      <dl>
        <dt><label>Modèle : </label></dt>
        <dd>
            <select id="ess_iModelId" name="ess_iModelId" style="width:158px;">
                {if isset($voiture)} 
                    {foreach $modeles as $item}
                    <option value="{$item->modele_id}" 
                            {if ($item->modele_id == $voiture->Occas_Modele)} selected {/if}
                            >{$item->modele_libelle}</option>
                    {/foreach}
                {else}
                    {foreach $modeles as $item}
                    <option value="{$item->modele_id}">{$item->modele_libelle}</option>
                    {/foreach}
                {/if}
            </select>
        </dd>
      </dl>
      <dl>
        <dt><label>Version : </label></dt>
        <dd><input type="text" value="{if (isset($voiture))} {$voiture->Occas_Version} {/if}" name="ess_zVersion" style="width:156px;"  class = "requiredB"/></dd>
      </dl>
        <dl>
        <dt><label>Energie : </label></dt>
        <dd>
            <select id="voiture_energie" name="voiture_energie" style="width:158px;">
                <option value="1" {if (isset($voiture) && (1 == ($voiture->Occas_Carburation)))} selected {/if} >Essence</option>
                <option value="2" {if (isset($voiture) && (2 == ($voiture->Occas_Carburation)))} selected {/if}>Diesel</option>
                <option value="3" {if (isset($voiture) && (3 == ($voiture->Occas_Carburation)))} selected {/if}>GPL</option>
                <option value="4" {if (isset($voiture) && (4 == ($voiture->Occas_Carburation)))} selected {/if}>Electrique</option>
                <option value="5" {if (isset($voiture) && (5 == ($voiture->Occas_Carburation)))} selected {/if}>BioEthanol</option>
            </select>
        </dd>
      </dl>
      <dl>
        <dt><label>Prix : </label></dt>
        <dd><input type="text" id ="prix" value="{if (isset($voiture->Occas_Prix))}{$voiture->Occas_Prix}{/if}" name="voiture_prix" style="width:158px;"  class = "requiredB numerique" /> euros</dd>
      </dl>
      <dl>
        <dt><label>à débattre : </label></dt>
        <dd><input type="checkbox" value="1" name="voiture_debattre" {if (isset($voiture) && (1 == ($voiture->Occas_Adebattre)))} checked {/if}/></dd>
      </dl>

      <dl>
        <dt><label>Mise en circulation : </label></dt>
        <dd>
            <select id="circulation_1" name="circulation_1" class="requiredB">
                <option value="0"></option>
                <option value="01">01</option>
                <option value="02">02</option>
                <option value="03">03</option>
                <option value="04">04</option>
                <option value="05">05</option>
                <option value="06">06</option>
                <option value="07">07</option>
                <option value="08">08</option>
                <option value="09">09</option>
                <option value="10">10</option>
                <option value="11">11</option>
                <option value="12">12</option>
            </select>
            <select id="circulation_2" name="circulation_2" class="requiredB">
                <option value="0"></option>
                {for $i = 0;$i < 60; $i++}
                    <option value="{$dateCirculation - $i}">{$dateCirculation - $i}</option>
                {/for}
            </select>
        </dd>
      </dl>
       <input type="hidden" id="dmc" value="{if (isset($voiture))}{$voiture->Occas_MiseCirculation}{/if}" />
       {literal}
       <script type="text/javascript">
           var date = $('#dmc').val();
           dates = date.split("-");
           $("#circulation_1 option").each(function(){
              if( $(this).attr("value") == dates[1]) $(this).attr("selected","selected") ;
           });
           $("#circulation_2 option").each(function(){
              if( $(this).attr("value") == dates[0]) $(this).attr("selected","selected") ;
           });
       </script>
       {/literal}
      <dl>
        <dt><label>Millesime : </label></dt>
        <dd>
            <select id="millesime" name="millesime" >
                <option value="0"></option>
                {for $i=0; $i < 3; $i++}
                    <option value="{$dateCirculation - $i}"
                            {if (isset($voiture) && (($voiture->Occas_Millesime) == ($dateCirculation - $i)) )} selected {/if}
                            >{$dateCirculation - $i}</option>
                {/for}
            </select>
        </dd>
      </dl>
       
  </div>
  <div id="caract-right">
        <dl>
            <dt><label>Kilométrage    : </label></dt>
            <dd><input type="text" id ="km" value="{if (isset($voiture))}{$voiture->Occas_Kilometrage}{/if}" name="km" class="requiredB"/></dd>
        </dl>
        <dl>
            <dt><label>Km moteur: </label></dt>
            <dd><input type="text" value="{if (isset($voiture))}{$voiture->Occas_Kilom_Moteur}{/if}" name="km-moteur" class="numerique"/> si différent</dd>
        </dl>
        <dl>
            <dt><label>Couleur: </label></dt>
            <dd><input type="text" value="{if (isset($voiture))}{$voiture->Occas_Couleur}{/if}" name="couleur"/> Métal<input type="checkbox" name="metal" value="1" {if (isset($voiture) && (($voiture->Occas_Coul_Metal) == 1) )} checked {/if}/></dd>
        </dl>
        <dl>
            <dt><label>Puis. fiscale: </label></dt>
            <dd><input type="text" value="{if (isset($voiture))}{$voiture->Occas_ChevFisc}{/if}" name="puiss-fiscal"/></dd>
        </dl>
        <dl>
            <dt><label>Nbre de portes: </label></dt>
            <dd>
                <select id="nb-porte" name="nb-porte" >
                    <option value="0"></option>
                    <option value="1" {if (isset($voiture) && (($voiture->Occas_NbPorte) == 1) )} selected {/if}>1</option>
                    <option value="2" {if (isset($voiture) && (($voiture->Occas_NbPorte) == 2) )} selected {/if}>2</option>
                    <option value="3" {if (isset($voiture) && (($voiture->Occas_NbPorte) == 3) )} selected {/if}>3</option>
                    <option value="4" {if (isset($voiture) && (($voiture->Occas_NbPorte) == 4) )} selected {/if}>4</option>
                    <option value="5" {if (isset($voiture) && (($voiture->Occas_NbPorte) == 5) )} selected {/if}>5</option>
                </select>
             </dd>
        </dl>
        <dl>
            <dt><label>Boîte : </label></dt>
            <dd>
                <select id="boite" name="boite" >
                    <option value="4" {if (isset($voiture) && (($voiture->Occas_Bt_Vitesse) == 4) )} selected {/if}>4 vitesses</option>
                    <option value="5" {if (isset($voiture) && (($voiture->Occas_Bt_Vitesse) == 5) )} selected {/if}>5 vitesses</option>
                    <option value="6" {if (isset($voiture) && (($voiture->Occas_Bt_Vitesse) == 6) )} selected {/if}>6 vitesses</option>
                    <option value="9" {if (isset($voiture) && (($voiture->Occas_Bt_Vitesse) == 9) )} selected {/if}>automatique</option>
                </select>
             </dd>
        </dl>
        <dl>
            <dt><label>1ère main: </label></dt>
            <dd><input type="checkbox" value="1" name="main" {if (isset($voiture) && (($voiture->Occas_Premieremain) == 1) )} checked {/if}/></dd>
        </dl>
        <dl>
        <dt><label>Garantie: </label></dt>
        <dd>
            <select id="garantie_1" name="garantie_1"   class = "requiredB">
                <option value="0"></option>
                <option value="01">01</option>
                <option value="02">02</option>
                <option value="03">03</option>
                <option value="04">04</option>
                <option value="05">05</option>
                <option value="06">06</option>
                <option value="07">07</option>
                <option value="08">08</option>
                <option value="09">09</option>
                <option value="10">10</option>
                <option value="11">11</option>
                <option value="12">12</option>
            </select>
            <select id="garantie_2" name="garantie_2" class = "requiredB">
                <option value="0"></option>
                {assign $j=0}
                {while $j < 16}
                    <option value="{$dateCirculation + $j}">{$dateCirculation + $j}</option>
                    {assign $j++}
                {/while}
            </select>
        </dd>
      </dl>
      <input type="hidden" id="gar" value="{if (isset($voiture))}{$voiture->Occas_Garantie}{/if}" />
       {literal}
       <script type="text/javascript">
           var date = $('#gar').val();
           dates = date.split("-");
           $("#garantie_1 option").each(function(){
              if( $(this).attr("value") == dates[1]) $(this).attr("selected","selected") ;
           });
           $("#garantie_2 option").each(function(){
              if( $(this).attr("value") == dates[0]) $(this).attr("selected","selected") ;
           });
       </script>
       {/literal}
      <dl>
        <dt><label>Contrôle technique: </label></dt>
        <dd>
            <select id="ctrl-tech" name="ctrl-tech" >
                <option value=""></option>
                <option value="1" {if (isset($voiture) && (($voiture->Occas_CT) == 1) )} selected {/if}>Recalé</option>
                <option value="2" {if (isset($voiture) && (($voiture->Occas_CT) == 2) )} selected {/if}>Vierge</option>
                <option value="3" {if (isset($voiture) && (($voiture->Occas_CT) == 3) )} selected {/if}>OK</option>
                <option value="4" {if (isset($voiture) && (($voiture->Occas_CT) == 4) )} selected {/if}>Non nécessaire</option>
                <option value="5" {if (isset($voiture) && (($voiture->Occas_CT) == 5) )} selected {/if}>Non effectué</option>
            </select>
        </dd>
      </dl>
  </div>
</div>


